 <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 基础表格</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .page{height:30px;}
        .page a,.pagin span{border:1px solid #ccc;padding:5px;margin-top:10px;clear:both;margin-left:10px;}
        .page span{width:20px;float:left;text-align: center;}
        .page a:hover{color:#f0580c;border-color:#f0580c;}

        .num{color:darkred;margin-right:10px;}
        .download{float:right;}
        #csv-file{display:none;}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>佣金明细</h5>
                        <!--<div style="float:left;margin-left:20%;">-->
                            <!--总交易量 : <span class="num">{$sum[0].sum(volume)|round=###,2}</span>-->
                            <!--库存费 : <span class="num">{$sum[0].sum(swaps)|round=###,2}</span>-->
                            <!--手续费 : <span class="num">{$sum[0].sum(commission)|round=###,2}</span>-->
                            <!--总收益 : <span class="num">{$sum[0].sum(profit)|round=###,2}</span>-->
                        <!--</div>-->
                        <!--<a class="download" href="__URL__/downloadGroup/id/{$id}/type/{$type}/from/{$from}/to/{$to}/transaction_type/{$transaction_type}"><i class="fa fa-download"></i>下载>></a>-->
                    </div>
                    <div class="ibox-content">
                        <div class="row" style="border-bottom:1px solid #CCC;">
                            <form class="form-horizontal" id="searchForm" style="margin:auto;width:35%;" action="__URL__/downloadHistory" method="post">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">时间范围：</label>
                                    <div class="col-sm-8">
                                        <input type="text" id="from" value="{$from}" name="from" class="laydate-icon form-control layer-date" style="width:48%;"> -
                                        <input type="text" id="to" value="{$to}" name="to" class="laydate-icon form-control layer-date" style="width:48%;">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">交易类型：</label>
                                    <div class="col-sm-8">
                                        <select class="input-sm form-control input-s-sm inline" name="transaction_type">
                                            <option value="0" <if condition="$transaction_type eq 0">selected</if>>全部</option>
                                            <option value="1" <if condition="$transaction_type eq 1">selected</if>>短期交易</option>
                                            <option value="2" <if condition="$transaction_type eq 2">selected</if>>外汇交易</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">类型：</label>
                                    <div class="col-sm-8">
                                        <select class="input-sm form-control input-s-sm inline" name="type">
                                            <option value="1" <if condition="$type eq 1">selected</if>>账号</option>
                                            <option value="2" <if condition="$type eq 2">selected</if>>组别</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="csv-file" class="col-sm-3 control-label" style="padding:0;">
                                        <div class="btn btn-default">选择文件</div>
                                        <input type="file" id="csv-file"/>
                                    </label>
                                    <div class="col-sm-8" style="padding:0;">
                                        <input type="text" name="keywords" placeholder="多个之间用英文逗号 “,” 隔开" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-offset-3 col-sm-8">
                                        <button class="btn btn-sm btn-info" id="btn-search" type="submit">搜 索</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>订单号</th>
                                        <th>账号</th>
                                        <th>开仓时间</th>
                                        <th>交易类型</th>
                                        <th>交易品种</th>
                                        <th>交易量</th>
                                        <th>价格</th>
                                        <th>S / L</th>
                                        <th>T / P</th>
                                        <th>平仓时间</th>
                                        <th>关单价格</th>
                                        <th>手续费</th>
                                        <th>库存费</th>
                                        <th>获利</th>
                                        <th>备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <volist name="list" id="vo">
                                    <tr>
                                        <td><input type="checkbox" class="i-checks" name="input[]"></td>
                                        <td>{$vo.ticket}</td>
                                        <td>{$vo.login}</td>
                                        <td>{$vo.open_time}</td>
                                        <td><if condition="$vo.cmd eq 1">SELL<else/>BUY</if></td>
                                        <td>{$vo.symbol}</td>
                                        <td>{$vo['volume']/100|round=###,2}</td>
                                        <td>{$vo.open_price}</td>
                                        <td>{$vo.sl}</td>
                                        <td>{$vo.tp}</td>
                                        <td>{$vo.close_time}</td>
                                        <td>{$vo.close_price}</td>
                                        <td>{$vo.commission}</td>
                                        <td>{$vo.swaps}</td>
                                        <td>{$vo.profit|round=###,2}</td>
                                        <td>{$vo.comment}</td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                            <div class="page">{$page}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <include file="Index/common_js"/>
    <!-- Peity -->
    <script src="__PUBLIC__/admin/js/plugins/peity/jquery.peity.min.js"></script>
    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
    <!-- iCheck -->
    <script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/layer/laydate/laydate.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });

            laydate({
                elem: '#from', /*目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'*/
                event: 'focus', /*响应事件。如果没有传入event，则按照默认的click*/
                //format: 'YYYY-MM-DD hh:mm:ss',
            });
            laydate({
                elem: '#to', /*目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'*/
                event: 'focus' /*响应事件。如果没有传入event，则按照默认的click*/
            });
        });

        var index;
        $("#searchForm").Validform({
            btnSubmit:"#btn-search",
            //ajaxPost:true,
            tiptype: function(msg, o, cssctl) {
                //msg：提示信息;
                //o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
                //cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
                if (!o.obj.is("form")) { //验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
                    var objtip = o.obj.parent().siblings(".Validform_checktip");
                    cssctl(objtip, o.type);
                    objtip.text(msg);
                }
            },beforeSubmit:function(curform){
                index = layer.load();
            }
        });

        $('#csv-file').change(function (){/*上传csv*/
            // var formData = new FormData($("#csv-file")[0]);
            var formData = new FormData();
            formData.append("csv", $("#csv-file")[0].files[0]);
            index = layer.load();
            $.ajax({
                type: "POST",
                url: "__URL__/uploadCsv",
                dataType: 'json',
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    layer.close(index);
                    //alert(JSON.stringify(data));return;
                    //console.log(data);return;
                    if(data.status == 1) {
                        $('input[name=keywords]').val(data.msg);
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 2000});
                    }
                }, error: function (err) {
                    layer.close(index);
                    layer.msg('网络错误', {icon: 2, time: 2000});
                    console.log(err);
                }
            });
        });
    </script>
</body>
</html>
